﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ZdrDomoviSeznam.aspx.cs" Inherits="Sio.Mdm.Web.Instalacija.ZdrDomoviSeznam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>SIO - MDM :: Instalacija : Zdravstveni domovi</title>
<ext:XScript ID="XScript1" runat="server">
  <script type="text/javascript">
    var dodajZapis = function () {
      var grid = #{GridZdrDomoviSeznam};
      grid.getRowEditor().stopEditing();    
      grid.insertRecord(0, {
          ZdravstveniDomId: -99,
			    Naziv   : ""
      });
      
      grid.getView().refresh();
      grid.getSelectionModel().selectRow(0);
      grid.getRowEditor().startEditing(0);
    }
  var obcineRenderer = function (value) {					
			var r = StoreObcine.getById(value);
      if (Ext.isEmpty(r)) { return ""; }
      return r.data.Naziv;
  };  

</script>
    </ext:XScript>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />

    <ext:Store ID="StoreObcine" runat="server">
			<Reader>
				<ext:JsonReader IDProperty="ObcinaId">
					<Fields>
						<ext:RecordField Name="ObcinaId" Type="Int" />						
						<ext:RecordField Name="Naziv" Type="String" />
					</Fields>
				</ext:JsonReader>
			</Reader>			
		</ext:Store>		
    
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
    <Content>
		                    
		<sio:GridPanel ID="GridZdrDomoviSeznam" runat="server" 
			StripeRows="true"
			TrackMouseOver="true">
     <Plugins>
         <ext:RowEditor ID="RowEditor1" runat="server" SaveText="Shrani" CancelText="Prekliči">
            <DirectEvents>
                <AfterEdit OnEvent="UrediPodatke">
									<ExtraParams>
										<ext:Parameter Mode="Raw" Name="data" Value="r.data" />
									</ExtraParams>
								</AfterEdit>
            </DirectEvents>
		</ext:RowEditor>         
		<ext:GridFilters ID="GridFilters1" runat="server">
		<Filters>
			<ext:NumericFilter DataIndex="ZdravstveniDomId" />
			<ext:StringFilter DataIndex="Naziv" />				
		</Filters>
		</ext:GridFilters>		
      </Plugins>			
		<Store>
			<ext:Store ID="StoreZdrDomoviSeznam" runat="server">
			<SortInfo Field="Naziv" />
			<Reader>
				<ext:JsonReader IDProperty="ZdravstveniDomId">
					<Fields>
						<ext:RecordField Name="ZdravstveniDomId" Type="Int" />
						<ext:RecordField Name="Naziv" Type="String" />
            <ext:RecordField Name="ObcinaId" Type="Int" />
					</Fields>
				</ext:JsonReader>
			</Reader>
			</ext:Store>			
		</Store>
	    
		<ColumnModel ID="ColumnModel1" runat="server">
		<Columns>
			<ext:RowNumbererColumn />
			<ext:Column ColumnID="ZdravstveniDomId" Hidden="true" Hideable="false" DataIndex="ZdravstveniDomId"></ext:Column>
			<ext:Column ColumnID="Naziv" Header="Naziv" DataIndex="Naziv" Width="150">
        <Editor>
				<ext:TextField ID="TextField1" runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite naziv zdravstvenega doma" BlankText="Vpišite naziv zdravstvenega doma" /></Editor>
      </ext:Column>
			<ext:Column Header="Občina" DataIndex="ObcinaId"  Width="150" >
				<Renderer Fn="obcineRenderer" />
				<Editor><ext:ComboBox ID="ComboBox3" runat="server"  TypeAhead="true" SelectOnFocus="true" Editable="true" Mode="Local" ForceSelection="true" 
						StoreID="StoreObcine" ValueField="ObcinaId" DisplayField="Naziv" /></Editor>
      </ext:Column>
		</Columns>
		</ColumnModel>
		
		<SelectionModel>
			<ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
		</SelectionModel>
		
		<TopBar>
			<ext:Toolbar ID="Toolbar1" runat="server" Width="500">
			<Items>
				<sio:Button ID="Button1" runat="server" Text="Dodaj" Icon="Add">
					<Listeners>
							<Click Fn="dodajZapis" />
          </Listeners>
				</sio:Button>
				<sio:Button ID="Button3" runat="server" Text="Briši" Icon="Delete">
        <DirectEvents>
					<Click OnEvent="OdstraniZapise" After="#{StoreZdrDomoviSeznam}.reload();" >
					<Confirmation ConfirmRequest="true" Message="Izbrišem izbrane zdravstvene domove?" />
					<ExtraParams>
						<ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridZdrDomoviSeznam}.getRowsValues({selectedOnly:true}))" />
					</ExtraParams>					
					</Click>
				</DirectEvents>	
				</sio:Button>

			</Items>
			</ext:Toolbar>
		</TopBar>
		
		</sio:GridPanel>
    
	</Content>
	</ext:Viewport>
    
  </form>
</body>
</html>
